/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EL;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author Tian
 */
@Entity
@Table(name = "Account")
@NamedQueries(
{
    @NamedQuery(name = "Accounts.findAll", query = "SELECT a FROM Accounts a")
})
public class Accounts implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "username")
    private String username;
    @Column(name = "password")
    private String password;
    @Column(name = "fullname")
    private String fullname;
    @Column(name = "dob")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dob;
    @Column(name = "userRole")
    private String userRole;
    @Column(name = "imgPath")
    private String imgPath;
    @JoinColumn(name = "contactID", referencedColumnName = "id")
    @OneToOne
    private Contacts contacts;
    @OneToMany(cascade = {CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH}, mappedBy = "accounts")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<Reservations> reservationsList;
    @OneToMany(cascade = {CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH},mappedBy = "accounts")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<FoodOrders> foodOrdersList;

    public Accounts()
    {
    }

    public Accounts(String username, String password, String fullname, Date dob, String imgPath)
    {
        this.username = username;
        this.password = password;
        this.fullname = fullname;
        this.dob = dob;
        this.imgPath = imgPath;
    }

    public Accounts(String username, String password, String fullname, Date dob, String userRole, String imgPath)
    {
        this.username = username;
        this.password = password;
        this.fullname = fullname;
        this.dob = dob;
        this.userRole = userRole;
        this.imgPath = imgPath;
    }
    

    public Accounts(Integer id)
    {
        this.id = id;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getUsername()
    {
        return username;
    }

    public void setUsername(String username)
    {
        this.username = username;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getFullname()
    {
        return fullname;
    }

    public void setFullname(String fullname)
    {
        this.fullname = fullname;
    }

    public Date getDob()
    {
        return dob;
    }

    public void setDob(Date dob)
    {
        this.dob = dob;
    }

    public String getUserRole()
    {
        return userRole;
    }

    public void setUserRole(String userRole)
    {
        this.userRole = userRole;
    }

    public String getImgPath()
    {
        return imgPath;
    }

    public void setImgPath(String imgPath)
    {
        this.imgPath = imgPath;
    }

    public Contacts getContacts()
    {
        return contacts;
    }

    public void setContacts(Contacts contacts)
    {
        this.contacts = contacts;
    }

    public List<Reservations> getReservationsList()
    {
        return reservationsList;
    }

    public void setReservationsList(List<Reservations> reservationsList)
    {
        this.reservationsList = reservationsList;
    }

    public List<FoodOrders> getFoodOrdersList()
    {
        return foodOrdersList;
    }

    public void setFoodOrdersList(List<FoodOrders> foodOrdersList)
    {
        this.foodOrdersList = foodOrdersList;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accounts))
        {
            return false;
        }
        Accounts other = (Accounts) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "EL.Accounts[id=" + id + "]";
    }

}
